<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html > 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

<ui:composition>
<div class="row-fluid" style="background: #FFFFFF;">
<div class="span1"></div>
	<div class="span10">
		<br />
		<h3>Consultar a Conta</h3>
		<br />
		<h:form prependId="false" id="formConsultConta">
			<p:growl id="growl" showDetail="true" sticky="true" life="6000"/>
			<div class="row-fluid">
				<div class="span2">
					<h:outputLabel for="cliente" value="Consulta por Cliente: " />
				</div>
				<div class="span4">
					<h:selectOneMenu id="cliente"
						value="#{conContaBean.clienteSelecionado}" requiredMessage="Escolha o Cliente">
						<f:selectItem itemLabel="Selecione o Cliente" itemValue="" />
						<f:selectItems value="#{conContaBean.listaItemCliente}" />
						
						<f:ajax listener="#{conContaBean.zeraLista()}" render=":formConsultConta :formListaConta :formListaAll"/>
					</h:selectOneMenu>
				</div>
			</div>
			<div class="span12">
				<div class="span5">
					<p:commandButton id="btConsultar" value="Consultar" ajax="true"
									 actionListener="#{conContaBean.consultarContaCliente}" update="@this growl :formListaConta" 
									icon="ui-icon-search" style="margin:0; margin-top:15px;" >
					</p:commandButton>
					<p:commandButton id="btConsultarTodos" value="Consultar Todos" ajax="true"
									 actionListener="#{conContaBean.consultarConta}" update="@this growl :formListaAll" 
									icon="ui-icon-search" style="margin:0; margin-top:15px; margin-left:10px;" >
					</p:commandButton>
				</div>
			</div>
			<div class="span12"></div>
		</h:form>
			<div class="row-fluid">
				<div class="span12">
					<h:form prependId="false" id="formListaConta">
					<div class="span3">
						<p:outputLabel value="Cliente: #{conContaBean.cliente.nome}" />
					</div>
					<div class="span12">	
						<h:outputText value="Valor Total dos Débitos: R$" /><h:outputText id="valTotalLista" value="#{conContaBean.precoTotalLista}" >
							<f:convertNumber maxFractionDigits="2"
								groupingUsed="true"
	    						currencySymbol="R$"
	   							maxIntegerDigits="4"
	   							type="currency"/>
						</h:outputText>
					</div>
					<div class="span12">	
						<h:outputText value="Valor Total de Crédito: " rendered="#{conContaBean.showCred}"/>
						<h:outputText id="totalCred" value="#{conContaBean.totalCredito}" rendered="#{conContaBean.showCred}">
							<f:convertNumber maxFractionDigits="2"
	    						groupingUsed="true"
	    						currencySymbol="R$"
	   							maxIntegerDigits="4"
	   							type="currency"/>
						</h:outputText>
					</div>
					</h:form>
				</div>
			</div>
		 	<div class="row=fluid">
		 		<div class="span12">
		 		<h:form prependId="false" id="formListaAll">
		 		<h:outputLabel value="Lista de Clientes com Debito no Caixa" rendered="#{conContaBean.showConta}"/>
		 		<p:dataTable value="#{conContaBean.listaConta}" var="list" rendered="#{conContaBean.showConta}">
		 				<p:column style="max-width: 300px; min-width: 150px; overflow: hidden">
		 					<f:facet name="header">
		 						<h:outputText value="Cliente:" />
		 					</f:facet>
		 					<h:outputText value="#{list.cliente.nome}" />
		 				</p:column>
						<p:column style="max-width: 200px; min-width: 100px; overflow: hidden">
		 					<f:facet name="header">
		 						<h:outputText value="Valor da Conta:" />
		 					</f:facet>
		 					<h:outputText value="#{list.valorTotal}" />
		 				</p:column>
		 			</p:dataTable>
		 			<BR />
		 			<h:outputLabel value="Lista de Clientes com Crédito no Caixa" rendered="#{conContaBean.showConta}"/>
		 			<p:dataTable value="#{conContaBean.listaCredito}" var="listc" rendered="#{conContaBean.showConta}">
		 				<p:column style="max-width: 300px; min-width: 150px; overflow: hidden">
		 					<f:facet name="header">
		 						<h:outputText value="Cliente:" />
		 					</f:facet>
		 					<h:outputText value="#{listc.cliente.nome}" />
		 				</p:column>
						<p:column style="max-width: 200px; min-width: 100px; overflow: hidden">
		 					<f:facet name="header">
		 						<h:outputText value="Valor do Credito:" />
		 					</f:facet>
		 					<h:outputText value="#{listc.valorTotal}" />
		 				</p:column>
		 			</p:dataTable>
		 		</h:form>
		 		</div>
		 	</div>
	</div>
	<div class="span1"></div>
</div>
</ui:composition>
</html>